package zy1204;

public class zy1 {
    public static void main(String[] args) throws Exception {
        String s = "q";
        int i = stringToNumber(s);
        System.out.println(i);
    }
    public static int stringToNumber(String s) throws Exception {
        if (s.equals(null)){
            throw new Exception("字符串不能为null");
        }else if (s.isEmpty()){
            throw new RuntimeException("字符串不能为空");
        }
        try {
            return Integer.parseInt(s);
        } catch (Exception e) {
            throw new RuntimeException("字符串转换失败");
        }
    }
}
